// ignore: avoid_web_libraries_in_flutter

//配置路由
import 'package:flutter/material.dart';
import 'package:flutter_app2/testPage.dart';
import 'package:flutter_app2/view/FocusTestRoute.dart';
import 'package:flutter_app2/view/FormTestRoute.dart';
import 'package:flutter_app2/view/LayoutBuilderRoute.dart';
import 'package:flutter_app2/view/page_view_second.dart';
import 'package:flutter_app2/view/ParentWidgetCPage.dart';
import 'package:flutter_app2/view/ProgressRoute.dart';
import 'package:flutter_app2/view/RouterTestRoutePage.dart';
import 'package:flutter_app2/view/ScaffoldRoute.dart';
import 'package:flutter_app2/view/ScrollNotificationTestRoute.dart';
import 'package:flutter_app2/view/SwitchAndCheckBoxTestRoute.dart';
import 'package:flutter_app2/view/tab_view_route.dart';
import 'package:path/path.dart';

final routes = {
  '/': (context, {arguments}) => ParentWidgetC(),
  '/route_test': (context) => RouterTestRoute(),
  '/parent_widget_c': (context) => ParentWidgetC(),
  '/switch_check': (context) => SwitchAndCheckBoxTestRoute(),
  '/test_page': (context) => TestPage(),
  '/focus_test_route': (context) => FocusTestRoute(),
  '/from_test_route': (context) => FormTestRoute(),
  '/progress_test_route': (context) => ProgressRoute(),
  '/layout_builder_route': (context) => LayoutBuilderRoute(),
  '/scaffold_route': (context) => ScaffoldRoute(),
  '/ScrollNotificationTestRoute': (context) => ScrollNotificationTestRoute(),
  '/PageView2': (context) => PageView2(),
  '/TabViewRoute1': (context) => TabViewRoute1(),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function pageContentBuilder = routes[name] as Function;
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
